package yxy.game.pm2.command.plainsCraft;

import yxy.cherry.game.base.message.MessageEmitterHandler;
import yxy.cherry.game.base.message.annotation.MessageSource;
import yxy.cherry.game.base.message.annotation.MessageType;
import yxy.game.pm2.Result;
import yxy.game.pm2.command.Command;
import yxy.game.pm2.message.PlainsCraftMessage;
import yxy.game.pm2.module.plainsCraft.PlainsCraftHandle;

/** 中原争霸 中原争霸主界面 */
@MessageType(proto = Command.PlainsCraftMain, classtype = PlainsCraftMessage.PlainsCraftMainRequest.class)
public class CMD_PlainsCraftMain extends Command<PlainsCraftMessage.PlainsCraftMainRequest> {

	@Override
	public void execute(MessageSource messageSource, PlainsCraftMessage.PlainsCraftMainRequest request) {
		String playerCode = messageSource.getTag();

		PlainsCraftMessage.PlainsCraftMainResponse.Builder response = PlainsCraftMessage.PlainsCraftMainResponse.newBuilder();

		Result result = new PlainsCraftHandle().mainInfo(playerCode, response);

		send(messageSource, response, result);
	}

	private void send(MessageSource messageSource, PlainsCraftMessage.PlainsCraftMainResponse.Builder response, Result result) {
		response.setResult(result.packResult());
		MessageEmitterHandler.getInstance().send(messageSource, response.build());
	}
}